package com.framework.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.dao.TerminalTypeDao;
import com.framework.entity.sys.SysAgent;
import com.framework.entity.ter.TerTerminalType;
import com.framework.exception.RRException;
import com.framework.exception.menu.RespCode;
import com.framework.service.AgentService;
import com.framework.service.TerminalTypeService;
import com.framework.view.TerTypeView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author wq
 */
@Service("terminalTypeService")
public class TerminalTypeServiceImpl extends ServiceImpl<TerminalTypeDao, TerTerminalType> implements TerminalTypeService {

    @Autowired
    private AgentService agentService;



    @Override
    public List<TerTerminalType> queryTerminalTypeList(Long deptId) {
        if (deptId == null || deptId == 0) {
            throw new RRException(RespCode.NOT_PARAM_ERROR);
        }
        return baseMapper.queryTerminalTypeList(deptId);
    }
    @Override
    public List<TerTerminalType> queryTerminalTypeByTokenList(String token) {
        SysAgent agent = agentService.queryAgentByToken(token);
        return baseMapper.queryTerminalTypeByTokenList(agent.getAgentId());
    }


	@Override
	public List<Map<String, Object>> queryTerminalModelList(String token) {
		SysAgent agent = agentService.queryAgentByToken(token);
		Long deptId = agent.getDeptId();
		List<Map<String, Object>> list = baseMapper.queryTerminalModelList(deptId);
		return list;
	}


	@Override
	public List<TerTerminalType> queryIsEnableList(Long deptId) {
		return baseMapper.queryIsEnableList(deptId);
	}

	@Override
	public List<Map<String, Object>> getTypeAndModel(Long deptId){
        List<Map<String, Object>> list=  baseMapper.getTypeAndModel(deptId);
        return list;
    }

    @Override
    public List<Map<String, Object>> queryTypeAndModel(String token) {
        SysAgent sysAgent = agentService.queryAgentByToken(token);
        return getTypeAndModel(sysAgent.getDeptId());
    }


}
